<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.infodms.dms.common.Constant"%>
<%@ page import="com.infodms.dms.util.CommonUtils"%>
<%@ page import="com.infodms.dms.po.TtDealerActualSalesPO"%>
<%@ page import="com.infodms.dms.po.TtCustomerPO"%>
<%@taglib uri="/jstl/cout" prefix="c"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.List"%>
<%
	String contextPath = request.getContextPath();
%>    

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<jsp:include page="${contextPath}/common/jsp_head_new.jsp" />
<script type="text/javascript">
<!--
	function doInit(){
		var isFleet = '${isFleet}';
		var ctmType = '${ctmType}';
		if(isFleet == <%=Constant.IF_TYPE_YES%>){
			document.getElementById("is_fleet_show").style.display = "inline";
		}else{
			document.getElementById("is_fleet_show").style.display = "none";
		}
		if(ctmType == <%=Constant.CUSTOMER_TYPE_01%>){
			document.getElementById("ctm_table_id").style.display = "inline";
			document.getElementById("company_table").style.display = "none";
		}else{
			document.getElementById("ctm_table_id").style.display = "none";
			document.getElementById("company_table").style.display = "inline";
		}
	}
	
	function openWindowDialog(targetUrl){
		  var height = 500;
		  var width = 800;
		  var iTop = (window.screen.availHeight-30-height)/2;  //获得窗口的垂直位置      
		  var iLeft = (window.screen.availWidth-10-width)/2;   //获得窗口的水平位置
		  var params = "width="+width+",height="+height+",top="+iTop+",left="+iLeft+",scrollbars=yes,resizable=yes,status=no";
		  window.open(targetUrl,null,params);
	  }
	
	function chkFile() {
		var oTab = document.getElementById('fileUploadTab') ;
		var iLen = oTab.rows.length ;
		
		if (iLen <= 1) {
			return false ;
		} else {
			return true ; 
		}
	}
	//-->
</script>

<title>实销退车申请</title>
</head>
<body>
<div class="wbox">
<div class="navigation"><img src="<%=contextPath%>/img/nav.gif" />&nbsp;当前位置： 整车销售 &gt; 客户信息管理 &gt; 实销退车申请</div>
<form id="fm" name="fm" method="post"><input type="hidden" name="curPage" id="curPage" value="1" /> <input type="hidden" id="dlrId" name="dlrId" value="" />
<table class="table_edit" align=center>
	<tr class="tabletitle">
		<th colspan="4"><img class="nav" src="<%=contextPath%>/img/subNav.gif" />车辆资料</th>
	</tr>
	<tr class="cssTable">
		<td width="15%" align=right>VIN：</td>
		<td align=left>${salesVehicleInfo.VIN }</td>
		<td align=right>发动机号：</td>
		<td align=left>${salesVehicleInfo.ENGINE_NO }</td>
	</tr>
	<tr class="cssTable">
		<td align=right>车系代码：</td>
		<td align=left>${salesVehicleInfo.SERIES_NAME }</td>
		<td align=right>车系名称：</td>
		<td align=left>${salesVehicleInfo.SERIES_NAME }</td>
	</tr>
	<tr class="cssTable">
		<td align=right>车型代码：</td>
		<td align=left>${salesVehicleInfo.MODEL_CODE }</td>
		<td align=right>车型名称：</td>
		<td align=left>${salesVehicleInfo.MODEL_NAME }</td>
	</tr>
	<tr class="cssTable">
		<td align=right>颜色：</td>
		<td align=left>${salesVehicleInfo.COLOR }</td>
		<td align=right>&nbsp;</td>
		<td align=left>&nbsp;</td>
	</tr>
	<tr class="tabletitle">
		<th colspan="4"><img class="nav" src="<%=contextPath%>/img/subNav.gif" />销售信息</th>
	</tr>
	<tr class="cssTable">
		<td align="right">车牌号：</td>
		<td width="35%" align="left">${salesVehicleInfo.VEHICLE_NO }</td>
		<td width="15%" align="right">合同编号：</td>
		<td width="35%" align="left">${salesVehicleInfo.CONTRACT_NO }</td>
	</tr>
	<tr class="cssTable">
		<td align="right">开票日期：</td>
		<td align="left">
		${salesVehicleInfo.INVOICE_DATE }
		</td>
		<td align="right">发票编号：</td>
		<td align="left">${salesVehicleInfo.INVOICE_NO }</td>
	</tr>
	<tr class="cssTable">
		<td align="right">保险公司：</td>
		<td align="left">${salesVehicleInfo.INSURANCE_COMPANY }</td>
		<td align="right">保险日期：</td>
		<td align="left">
		${salesVehicleInfo.INSURANCE_DATE }
		</td>
	</tr>
	<tr class="cssTable">
		<td align="right">车辆交付日期：</td>
		<td align="left">
		${salesVehicleInfo.CONSIGNATION_DATE }
		</td>
		<td align="right">交付时公里数：</td>
		<td align="left">${salesVehicleInfo.MILES }</td>
	</tr>
	<tr class="cssTable">
		<td align="right">付款方式：</td>
		<td align="left" >
		<script>document.write(getItemValue(${salesVehicleInfo.PAYMENT}));</script>	
		</td>
		<td align="right">价格：</td>
		<td align="left">
			<script>document.write(numberFormat('#,###.00',${salesVehicleInfo.PRICE }));</script>
		</td>
	</tr>
	<tr class="cssTable">
		<td align="right">备注：</td>
		<td colspan="2" align="left">${salesVehicleInfo.MEMO }</td>
		<td align="left">&nbsp;</td>
	</tr>
</table>
<table class="table_edit" align="center" id="customer_type_table">
	<tr class="tabletitle">
		<th colspan="4"><img class="nav" src="<%=contextPath%>/img/subNav.gif" />客户类型</th>
	</tr>
	<tr class="cssTable">
		<td width="15%" align=right id="select_ctm_type_id">客户类型：</td>
		<td width="35%" align="left" id="select_ctm_type_id_1">
		<script>document.write(getItemValue(${salesCusInfo.CTM_TYPE}));</script>			
		</td>
		<td width="15%" align="right">是否集团客户：</td>
		<td width="35%" align="left">
			<script>document.write(getItemValue(${salesCusInfo.IS_FLEET}));</script>		
		</td>
	</tr>
	<tbody id="is_fleet_show" style="display: none;">
		<tr class="cssTable">
			<td align="right">集团客户名称：</td>
			<td align="left">
			<c:if test="${salesCusInfo.PACT_NAME!=null}">
			${salesCusInfo.PACT_NAME}
			</c:if>
				${salesCusInfo.FLEET_NAME}
			</td>
			<td align="right">集团客户合同：</td>
			<td align="left">
			<c:if test="${salesCusInfo.PACT_NAME!=null}">
			${salesCusInfo.PACT_NAME}
			</c:if>
				${salesCusInfo.CONTRACT_NO}
			</td>
		</tr>
	</tbody>
</table>
<table class="table_edit" align="center" id="company_table">
	<tr class="tabletitle">
		<th colspan="4" align="right"><img class="nav" src="<%=contextPath%>/img/subNav.gif" />公司客户信息</th>
	</tr>

	<tr class="cssTable">
		<td width="15%" align="right">公司名称：</td>
		<td width="35%" align="left">${salesCusInfo.COMPANY_NAME }</td>
		<td width="15%" align="right">公司简称：</td>
		<td width="35%" align="left">${salesCusInfo.COMPANY_S_NAME }</td>
	</tr>
	<tr class="cssTable">
		<td align="right">公司电话：</td>
		<td align="left">${salesCusInfo.COMPANY_PHONE }</td>
		<td align="right">公司规模 ：</td>
		<td align="left">
		<script>document.write(getItemValue(${salesCusInfo.LEVEL_ID}));</script>				
		</td>
	</tr>
	<tr class="cssTable">
		<td align="right">公司性质：</td>
		<td align="left">
		<script>document.write(getItemValue(${salesCusInfo.KIND}));</script>		
		</td>
		<td align="right">目前车辆数：</td>
		<td align="left">${salesCusInfo.CTM_TYPE}</td>
	</tr>
		<tr class="cssTable">
		<td align="right">客户来源：</td>
		<td align="left">
		<script>document.write(getItemValue(${salesCusInfo.KIND}));</script>		
		</td>
	</tr>
</table>
<div id="customerInfoid">
<table class="table_edit" align="center" id="ctm_table_id">
	<tr>
		<th colspan="4"><img class="nav" src="<%=contextPath%>/img/subNav.gif" />个人客户信息</th>
	</tr>
	<tr class="cssTable">
		<td width="15%" align="right" id="tcmtd">客户姓名：</td>
		<td width="35%" align="left">
		${salesCusInfo.CTM_NAME }
		</td>
		<td width="15%" align="right" id="sextd">性别：</td>
		<td align="left">
		<script>document.write(getItemValue(${salesCusInfo.SEX}));</script>			
		</td>
	</tr>

	<tr class="cssTable">
		<td align="right">证件类别：</td>
		<td align="left">
		<script>document.write(getItemValue(${salesCusInfo.CARD_TYPE}));</script>				
		</td>
		<td align="right">证件号码：</td>
		<td align="left">${salesCusInfo.CARD_NUM }</td>
	</tr>
	<tr class="cssTable">
		<td align="right">主要联系电话：</td>
		<td align="left">${salesCusInfo.MAIN_PHONE }</td>
		<td align="right">其他联系电话：</td>
		<td align="left">${salesCusInfo.OTHER_PHONE }</td>
	</tr>
	
	<tr class="cssTable">
		<td align="right">出生年月：</td>
		<td align="left">
		${salesCusInfo.BIRTHDAY }	
		</td>
	</tr>
	<tr class="cssTable">
		<td align="right">详细地址：</td>
		<td colspan="3" align="left">${salesCusInfo.ADDRESS }</td>
	</tr>
	<tr>
		<td align="right">购买用途：</td>
		<td align="left">
		<script>document.write(getItemValue(${salesVehicleInfo.SALES_ADDRESS}));</script>		
		</td>
		<td align="right">购买原因：</td>
		<td align="left">
		<script>document.write(getItemValue(${salesVehicleInfo.SALES_RESON }));</script>
		</td>
	</tr>
</table>
</div>
<!-- 添加附件start -->
	<table class="table_info" border="0" id="file">
	    <tr>
	        <th><img class="nav" src="<%=contextPath%>/img/subNav.gif" />&nbsp;附件列表<input type="hidden" id="fjid" name="fjid"/>
				<span>
					<input type="button" class="cssbutton"  onclick="showUpload('<%=contextPath%>')" value ='添加附件'/>
				</span>
			</th>
		</tr>
		<tr>
			<td width="100%" colspan="2"><jsp:include page="${contextPath}/uploadDiv.jsp" /></td>
  		</tr>
	</table>
	<!-- 添加附件end -->
<table class="table_edit" align="center" >
	<tr>
		<th colspan="4"><img class="nav" src="<%=contextPath%>/img/subNav.gif" />退车信息说明</th>
	</tr>
	<tr>
		<td align="right"><font color="red">该车已发生售后费用：</font></td>
		<td><font color="red"><strong>${scCost }</strong> 元，有售后费用的退车由总部批复</font></td>
	</tr>
	<tr>
		<td align="right">退车类型：</td>
		<td>
			<script type="text/javascript">
	            	genSelBoxExp("returnType",<%=Constant.SALE_RETURN%>,"",true,"mini_sel","","true",'');
	        </script>
	        <font color="red">*</font>
        </td>
	</tr>
	<tr class="cssTable">
		 <td align="right">退车原因：</td>
		 <td class="datadetail" align="left" colspan="3">
		 	<textarea id="returnReason" name="returnReason" rows="3" cols="50"  datatype="0,is_textarea,300" ></textarea>
		</td>
	</tr>
</table>
<br />
<table  class="table_edit" align="center" >
	<tr class="cssTable">
		<td align="center" colspan="6">
			<input class="normal_btn" type="button" value="维修历史" name="historyBtn" onclick="openWindowDialog('<%=contextPath%>/claim/dealerClaimMng/ClaimBillMaintainMain/maintaimHistory.do?VIN=${salesVehicleInfo.VIN }');" />
			<input class="normal_btn" type="button" value="授权历史" name="historyBtn" onclick="openWindowDialog('<%=contextPath%>/claim/dealerClaimMng/ClaimBillMaintainMain/auditingHistory.do?VIN=${salesVehicleInfo.VIN }');" />
			<input class="normal_btn" type="button" value="保养历史" name="historyBtn" onclick="openWindowDialog('<%=contextPath%>/claim/dealerClaimMng/ClaimBillMaintainMain/freeMaintainHistory.do?VIN=${salesVehicleInfo.VIN }');" />
			<input type="button" name="mySubmit"  class="normal_btn" value="提交" onclick="returnSubmit();" />
			<input type="hidden" name="orderId" value="${salesVehicleInfo.ORDER_ID }" />	<!-- 实销id -->
			<input type="hidden" name="vehicleId" value="${salesVehicleInfo.VEHICLE_ID }" /> <!-- 车辆id -->
			<input type="hidden" name="scCost" id="scCost" value="${scCost }" />
		</td>
	</tr>
</table>
</form>
</div>

<script type="text/javascript">
	function returnSubmit(){
		var scCost = parseFloat(document.getElementById("scCost").value) ;
		
		if(!chkFile() && scCost > 0) {
			MyAlert("存在售后费用的实销退车需要添加上传附件！") ;
			return false ;
		}
		
		var returnReason = document.getElementById("returnReason").value;
		var returnType = document.getElementById("returnType").value;
		if(returnType.length == 0) {
			MyAlert("请选择退车类型！");
			return;
		}
		if(returnReason.length == 0) {
			MyAlert("请输入退车原因！");
			return;
		}
		if(returnReason.length >0){
		if(returnReason.length >100){
			MyAlert("退车原因内容过多，请重新输入！");
			return;
		}else{
			var a = new Object();
			a = document.getElementById("mySubmit");
			a.disabled=true;
			if(confirm("是否退车?")){
				returnSubmitAction();
			}else{
				a.disabled=false;
			}
		}
		}else{
		MyAlert("退车原因输入不能为空");
		}
	}
	
	function returnSubmitAction(){
		fm.action = "<%=request.getContextPath()%>/sales/customerInfoManage/SalesVehicleReturn/reportSubmit.do";
		fm.submit();
	}
</script>
</body>
</html>